/*
  $Id: InteractiveInput.java 35 2014-05-19 13:23:21Z ssidek@gmail.com $
  $LastChangedBy: ssidek@gmail.com $
  $Revision: 35 $

  Description:
  Sample code to perform user interactive session

*/

import java.util.Scanner;
import java.io.IOException;
import java.lang.*;

public class InteractiveInput {

  /**
  * @clearScreen()
  */
  public static void clearScreen() {
    try {
      if (System.getProperty( "os.name" ).startsWith( "Window" )) {
        Runtime.getRuntime().exec("cls");
      } 
      else {
        Runtime.getRuntime().exec("clear");
      }
    } catch (IOException e) {
      for(int i = 0; i < 100; i++) {
        System.out.println();
      }
    }
  }

  /**
  * @viewCourseMenu()
  */
  public static void viewCourseMenu() {
    clearScreen();
    //String menuTitle      = "================= View Course =================";

    //System.out.println("");
    //System.out.println("\n" + menuTitle + "\n");
    //System.out.println("");

    System.out.println("Course List:\nC1. Intro to Java 1\nC2. Java 2\nC3. C++\n");

    //System.out.println("Menu:");
    //System.out.println("1. Sort Course List (alphabetical order)");
    //System.out.println("1. Select Course for more information");
    //System.out.println("2. Return to Main Menu");
    //System.out.println("");

    //System.out.print("Enter your selection: ");
  }

  /**
  * @loginMenu()
  */
  public static void loginMenu() {
    clearScreen();
    String menuTitle      = "================= Login =================";

    System.out.println("");
    System.out.println("\n" + menuTitle + "\n");
    System.out.println("");

    System.out.println("Menu:");
    System.out.println("1. Enter Username");
    System.out.println("2. Return to Main Menu");
    System.out.println("");

    System.out.print("Enter your selection: ");

  }

  /**
  * @createAccount()
  */
  public static void createAccountMenu() {
    clearScreen();
    String menuTitle      = "================= Create Account =================";

    System.out.println("");
    System.out.println("\n" + menuTitle + "\n");
    System.out.println(""); 
    //System.out.println("");

    System.out.println("Menu:");
    System.out.println("1. Enter UserID");
    System.out.println("2. Return to Main Menu");
    System.out.println("");

    System.out.print("Enter your selection: ");
  }

  /**
  * @userPageMenu()
  */
  public static void userPageMenu() {
    clearScreen();
    String menuTitle      = "================= User Homepage =================";
    
    System.out.println("");
    System.out.println("\n" + menuTitle + "\n");
    System.out.println("");

    System.out.println("Menu:");
    System.out.println("1. List Available Course");
    System.out.println("2. List Enrolled Course");
    System.out.println("3. Register for Course");
    System.out.println("4. Un-register Course");
    System.out.println("5. Return to Main Menu");
    System.out.println("");

    System.out.print("Enter your selection: ");
  }

  /**
  * @main()
  */
  public static void main(String args[]) {
    clearScreen();
    String courseID;
    String selectedMenu;
    String welcomeMessage = "==== Team C: Student Registration System ====";
    String menuTitle      = "================= Main Menu =================";
 
    Scanner userInput = new Scanner(System.in);
 
    System.out.println("\n" + welcomeMessage + "\n");

    System.out.println(menuTitle + "\n");

    viewCourseMenu();

    //System.out.println("");
    System.out.println("Menu:");
    //System.out.println("1. List Available Course");
    System.out.println("1. Login");
    System.out.println("2. Create Account (for new student)");
    System.out.println("3. Exit");
    System.out.println("");

    System.out.print("Enter your selection: ");
    selectedMenu = userInput.nextLine();

    switch ( selectedMenu ) {
      case "1":
        clearScreen();
        viewCourseMenu();
        break;
      case "2":
        loginMenu();
        break;
      case "3":
        createAccountMenu();
        break;
      case "4":
        System.exit(0);
      default:
        viewCourseMenu();
    }

    //System.out.println("Username entered: " + userName);
 
    //System.out.print("Select Course ID: ");
    //courseID = userInput.nextInt(); // to parse integer
    //courseID = userInput.nextLine();
    //System.out.println("Course ID selected: " + courseID);

    System.out.println("\n\n\n\n\n\n\n\n\n\n\n\n\n");
  
   }

}
